package ${packageName};

import com.zxn.presenter.view.BaseActivity;
import android.os.Bundle;
import android.content.Context;
import android.content.Intent;
import androidx.fragment.app.Fragment;
<#if applicationPackage??>
import ${applicationPackage}.R;
</#if>
<#if includeCppSupport!false>
</#if>
/**
 *	
 * Created by zxn on ${.now}.
 */
public class ${activityClass} extends BaseActivity {

    private static final String ARG_PARAM1 = "param1";
    private String mParam1;
    @BindView(R.id.stl_common)
    SlidingTabLayout stlCommon;
    @BindView(R.id.vp_common)
    ViewPager vpCommon;

<#if addTitleRight>
    @BindView(R.id.title_view)
    TitleView titleView;
</#if>
	
	public static void jumpTo(Context context,String param1) {
        Intent intent = new Intent(context, ${activityClass}.class);
        intent.putExtra(ARG_PARAM1, param1);
        context.startActivity(intent);
    }

    public static void jumpTo(Context context) {
        Intent intent = new Intent(context, ${activityClass}.class);
        context.startActivity(intent);
    }

    @Override
    protected int getLayoutResId() {
        return R.layout.${layoutName};
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
		mParam1 = getIntent().getStringExtra(ARG_PARAM1);
	<#if addTitleRight>
		onCreateTitleView();
	</#if>

		onCreateTabLayout(); 	
    }

<#if addTitleRight>
    private void onCreateTitleView() {
    <#if titleRightStyle == 'image'>
        ImageView view = new ImageView(mContext);
        view.setImageResource(R.drawable.ic_back_white);
	<#else>
        TextView view = new TextView(mContext);
        view.setText(R.string.${titleRightName});
        view.setTextColor(UIUtils.getColor(R.color.c_ffffff));
        view.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15);		
	</#if>		     
        view.setOnClickListener(v -> {
			showToast("setOnClickListener");
        });
        titleView.addRightView(view);
    }
</#if>

	private void onCreateTabLayout() {
        ArrayList<Fragment> fragments = new ArrayList<>();
        //fragments.add(OtherBookFragment.newInstance());
        vpCommon.setAdapter(new PagerAdapter(getSupportFragmentManager(), fragments));
        vpCommon.setOffscreenPageLimit(3);

        stlCommon.setViewPager(vpCommon);
        //stlCommon.setOnTabSelectListener(this);

        //stlCommon.showMsg(0, 66);
        //stlCommon.showMsg(1, 100);
        //stlCommon.showMsg(2, 16);

        /*for (int i = 0; i < stlCommon.getTabCount(); i++) {
            stlCommon.setMsgMargin(i, 60, 12);
            MsgView mClassifyMsgView0 = stlCommon.getMsgView(i);
            if (mClassifyMsgView0 != null) {
                mClassifyMsgView0.setStrokeWidth(0);
                mClassifyMsgView0.setBackgroundColor(UIUtils.getColor(R.color.c_3f51b5));
            }
        }*/
    } 
}
